package com.xmg.client.mgrsite.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.xmg.shop.api.order.page.PageResult;
import com.xmg.shop.api.order.query.OrderInfoQueryObject;
import com.xmg.shop.api.order.service.IOrderActionService;
import com.xmg.shop.api.order.service.IOrderInfoService;
import com.xmg.shop.api.order.service.IOrderProductService;
import com.xmg.shop.api.order.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class OrderController {
    @Reference
    private IOrderInfoService orderInfoService;
    @Reference
    private IUserService userService;
    @Reference
    private IOrderProductService orderProductService;
    @Reference
    private IOrderActionService orderActionService;
    @RequestMapping("/order")
    public String orderList(@ModelAttribute("qo")OrderInfoQueryObject qo, Model model){
        PageResult pageResult = orderInfoService.queryPage(qo);
        model.addAttribute("pageResult",pageResult);
        return "order/orderList";
    }

    @RequestMapping("/orderDetail")
    public String orderDetail(Model model,Long id){
        model.addAttribute("actions",orderActionService.selectAll());
        model.addAttribute("product",orderProductService.selectByPrimaryKey(id));
        model.addAttribute("info",orderInfoService.selectByPrimaryKey(id));
        model.addAttribute("user",userService.selectByPrimaryKey(id));
        return "order/order_detail";
    }
}
